Skip to content

fix: reject excessive AllocRingBuffer allocations#149

Merged
NULLx76 merged 4 commits into
NULLx76:mainfrom
Sieger9303:fix-alloc-ringbuffer-large-allocation
May 23, 2026
Merged

fix: reject excessive AllocRingBuffer allocations#149
NULLx76 merged 4 commits into
NULLx76:mainfrom
Sieger9303:fix-alloc-ringbuffer-large-allocation

Conversation

@Sieger9303
Copy link
Copy Markdown
Contributor

Fixes #148 .

Hi, thanks for maintaining this crate.

AllocRingBuffer::new allocates a heap buffer based on the requested capacity rounded up to the next power of two. Very large capacities can produce a valid layout while still requesting an impractically large allocation, which can lead to resource exhaustion under tools such as Miri.

This PR adds a lightweight upper-bound check on the computed allocation size before calling the allocator. The public API shape is unchanged; excessive capacities now fail predictably with a Rust panic instead of reaching the raw allocation path.

@NULLx76
Copy link
Copy Markdown
Owner

NULLx76 commented May 23, 2026

Thanks for your contribution :)

@NULLx76 NULLx76 merged commit d4175c8 into NULLx76:main May 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential soundnessissue in AllocRingBuffer::new for very large capacities

2 participants